package com.lepu.app.fun.index.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.app.utils.BitmapLoadUtil;
import com.core.lib.utils.photo.UniversalImageLoadTool;
import com.core.lib.widget.CircularImageView;
import com.eyzhs.app.R;
import com.lepu.app.fun.index.activity.IndexWriterBannerActivity;
import com.lepu.app.fun.index.bean.BeanWriterHead;

public class WriterHeadView extends LinearLayout {

	private Context mContext;
	private BeanWriterHead mWriterHead;

	private CircularImageView mAvatat;
	private TextView mName;
	private TextView mContent;

	public WriterHeadView(Context context, BeanWriterHead writerHead) {
		super(context);

		mContext = context;
		mWriterHead = writerHead;

		LayoutInflater.from(mContext).inflate(R.layout.writer_head_view, this,
				true);
		init();
	}

	public WriterHeadView(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	private void init() {
		mAvatat = (CircularImageView) findViewById(R.id.avatar);
		mName = (TextView) findViewById(R.id.name);
		mContent = (TextView) findViewById(R.id.content);

		try {
			FrameLayout bgFramgeLayout = (FrameLayout) findViewById(R.id.bgFramgeLayout);
			bgFramgeLayout.setBackgroundResource(R.drawable.writer_head_view_bg);
		}catch (OutOfMemoryError e){
		}

		BitmapLoadUtil.displayImage(R.drawable.app_ic_default_avatar_64,mWriterHead.Avatar,mAvatat);
		//UniversalImageLoadTool.disPlay(mWriterHead.Avatar, mAvatat, R.drawable.app_ic_default_avatar_64);
		mName.setText(mWriterHead.AuthorName);
		mContent.setText(mWriterHead.Resume);
		
		ImageView backIamge = (ImageView) findViewById(R.id.backImageView);
		backIamge.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				if(IndexWriterBannerActivity.getInstance() == null){
					return;
				}
				IndexWriterBannerActivity.getInstance().finish(true);
			}
		});
	}

}
